﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace BioCyber_Infection
{
    class MainMenuScreen
    {
        SpriteFont arial14;
        GameWindow window;
        Rectangle startGameButtonSource, creditsButtonSource, quitGameButtonSource, optionsButtonSource;
        Texture2D startGameButton, creditsGameButton, quitGameButton, backgroundImage;

        /// <summary>
        /// Construtor
        /// </summary>
        public MainMenuScreen(GameWindow gameWindow, ContentManager content)
        {
            this.window = gameWindow;

            this.startGameButton = content.Load<Texture2D>("startGameButton");
            this.creditsGameButton = content.Load<Texture2D>("creditsButton");
            this.quitGameButton = content.Load<Texture2D>("quitButton");
            this.backgroundImage = content.Load<Texture2D>("background");

            arial14 = content.Load<SpriteFont>("SpriteFont1");

            startGameButtonSource = new Rectangle((int)(window.ClientBounds.Width * 0.05), 100, 110, 25);
            optionsButtonSource = new Rectangle((int)(window.ClientBounds.Width * 0.05), 150, 75, 25);
            creditsButtonSource = new Rectangle((int)(window.ClientBounds.Width * 0.05), 200, 75, 25);
            quitGameButtonSource = new Rectangle((int)(window.ClientBounds.Width * 0.05), 250, 50, 25);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            /*
            spriteBatch.Draw(startGameButton, startGameButtonSource, Color.White);
            spriteBatch.Draw(creditsGameButton, creditsButtonSource, Color.White);
            spriteBatch.Draw(quitGameButton, quitGameButtonSource, Color.White);*/
            spriteBatch.Draw(backgroundImage, new Rectangle(0, 0, window.ClientBounds.Width, window.ClientBounds.Height), Color.White);

            spriteBatch.DrawString(arial14, "Start Game", new Vector2((float)(startGameButtonSource.X), (float)(startGameButtonSource.Y)), Color.White);
            spriteBatch.DrawString(arial14, "Options", new Vector2((float)(optionsButtonSource.X), (float)(optionsButtonSource.Y)), Color.White);
            spriteBatch.DrawString(arial14, "Credits", new Vector2((float)(creditsButtonSource.X), (float)(creditsButtonSource.Y)), Color.White);
            spriteBatch.DrawString(arial14, "Quit", new Vector2((float)(quitGameButtonSource.X), (float)(quitGameButtonSource.Y)), Color.White);
        }

        public void Update(GameTime gameTime)
        {
            if (Mouse.GetState().LeftButton == ButtonState.Pressed && Engine.currentState == Engine.gameState.MAINMENU)
            {
                if (Engine.isColliding(startGameButtonSource,Engine.mousePos))
                {
                    Engine.currentState = Engine.gameState.HISTORY;
                }
                if (Engine.isColliding(optionsButtonSource, Engine.mousePos))
                {
                    Engine.currentState = Engine.gameState.OPTIONS;
                }
                if (Engine.isColliding(creditsButtonSource,Engine.mousePos))
                {
                    Engine.currentState = Engine.gameState.CREDITS;
                }
                if (Engine.isColliding(quitGameButtonSource,Engine.mousePos))
                {
                    Engine.currentState = Engine.gameState.QUIT;
                }
            }
        }
    }
}
